<template>
	<view class="container">
		<u-toast ref="uToast" />
		<u-navbar :is-back="true" title="审核" back-icon-color='#333333' height="50" :border-bottom="false">
		</u-navbar>
		<view class="list">
			<view class="description">
				<text>姓名</text>
				<text>{{name}}</text>
			</view>
			<view class="clbum">
				<text>班级</text>
				<text>{{grade_name}}</text>
			</view>
			<view class="student_number">
				<text>学号</text>
				<text>{{student_id}}</text>
			</view>
			<view class="start_time">
				<text>开始时间</text>
				<text>{{start_time}}</text>
				<image src="../../static/tupian105.png" mode="widthFix"></image>
			</view>
			<view class="end_time">
				<text>结束时间</text>
				<text>{{end_time}}</text>
				<image src="../../static/tupian105.png" mode="widthFix"></image>
			</view>
			<view class="reason">
				<text>原因</text>
				<text>{{audit_type}}</text>
				<text></text>
			</view>
			<view class=""
				style="width:94%; height:15rpx; margin-left:3%; background:#F2F2F2; border-top-left-radius:12rpx; border-top-right-radius:12rpx;">

			</view>
			<textarea value="" v-model="reason_content" placeholder="请输入详细原因"
				style="width:94%; height:160rpx; margin-left:3%; background:#F2F2F2; text-indent:1em; border-bottom-left-radius:12rpx; border-bottom-right-radius:12rpx;" />
			<view class="adjunct">
				<text class="upload">上传附件</text>
				<view class="num">
					<text>上传附件</text>
					<text>{{files}}</text>
					<text>个</text>
				</view>
			</view>
			<view class="results">
				<text class="check">审核结果</text>
				<view class="toggle">
					<text :style="{color:left_color,background:left_background_color}"
						@click="changeLeftColor">通过</text>
					<text :style="{color:right_color,background:right_background_color}"
						@click="changeRightColor">驳回</text>
				</view>
			</view>
			<view class="remark">
				审核备注
			</view>
			<view class=""
				style="width:94%; height:15rpx; margin-left:3%; background:#F2F2F2; border-top-left-radius:12rpx; border-top-right-radius:12rpx;">

			</view>
			<textarea value="" v-model="form.remark" placeholder="多行输入"
				style="width:94%; height:160rpx; margin-left:3%; background:#F2F2F2; text-indent:1em; border-bottom-left-radius:12rpx; border-bottom-right-radius:12rpx;" />
			<view class="" style="width:100%; height:30rpx;">
			</view>
		</view>
		<view class="confirm">
			<view class="verify" @click="leaveHandle">
				{{verify}}
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../request.js'
	export default {
		data() {
			return {
				type: 'text',
				border: false,
				content: '',
				license_content: '',
				driver_content: '',
				available_content: '',
				number_content: '',
				input_content: '',
				reason_content: '',
				boolen: false,
				name: '',
				grade_name: '',
				student_id: '',
				start_time: '',
				end_time: '',
				audit_type: '',
				files: '',
				verify: '确认',
				left_color: '#fff',
				left_background_color: '#00cd97',
				right_color: '#333333',
				right_background_color: '#F2F2F2',
				form: {
					remark: '',
					handle: 1,
					student_leave_id: '',
				},
			}
		},
		onLoad(option) {
			console.log(option);
			if (option) {
				this.name = option.name;
				this.grade_name = option.class;
				this.student_id = option.student_id;
				this.start_time = option.start_time;
				this.end_time = option.end_time;
				this.audit_type = option.type;
				this.reason_content = option.reason;
				this.files = option.files ? option.files.split(',').length : 0;
				this.form.student_leave_id = option.student_leave_id;
			}
		},
		methods: {
			changeLeftColor() {
				if (this.left_background_color == '#00cd97') {
					this.left_color = '#333333';
					this.left_background_color = '#F2F2F2';
					this.right_color = '#fff';
					this.right_background_color = '#00cd97';
				} else {
					this.left_color = '#fff';
					this.left_background_color = '#00cd97';
					this.right_color = '#333333';
					this.right_background_color = '#F2F2F2';
					this.form.handle = 1;
				}
			},
			changeRightColor() {
				if (this.right_background_color == '#00cd97') {
					this.right_color = '#333333';
					this.right_background_color = '#F2F2F2';
					this.left_color = '#fff';
					this.left_background_color = '#00cd97';
				} else {
					this.right_color = '#fff';
					this.right_background_color = '#00cd97';
					this.left_color = '#333333';
					this.left_background_color = '#F2F2F2';
					this.form.handle = 2;
				}
			},
			leaveHandle() {
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				let _this = this;
				request({
					url: base_url + 'teacher/student_leave/handle',
					data: {
						...this.form,
					},
					method: 'post',
					success(res) {
						if (res.statusCode == 200) {
							console.log(res.data);
							_this.$toLink('../request_absence/request_absence', {},2)
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			},
		}

	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		background-color: #F2F2F2;

		.list {
			background-color: #fff;
			margin-top: 20rpx;
			width: 710rpx;
			margin-left: 20rpx;
			border-radius: 12rpx;

			.description {
				width: 94%;
				margin-left: 3%;
				height: 90rpx;
				border-bottom: 1px solid #F2F2F2;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
					}

					&:nth-child(2) {
						color: #333333;
						font-size: 26rpx;
						text-align: right;
						width: 600rpx;
					}

				}
			}

			.clbum {
				width: 94%;
				margin-left: 3%;
				height: 90rpx;
				border-bottom: 1px solid #F2F2F2;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
					}

					&:nth-child(2) {
						color: #333333;
						font-size: 26rpx;
						text-align: right;
						width: 600rpx;
					}

				}
			}

			.student_number {
				width: 94%;
				margin-left: 3%;
				height: 90rpx;
				border-bottom: 1px solid #F2F2F2;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
					}

					&:nth-child(2) {
						color: #333333;
						font-size: 26rpx;
						text-align: right;
						width: 600rpx;
					}

				}
			}

			.start_time {
				width: 94%;
				margin-left: 3%;
				height: 90rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				border-bottom: 1px solid #F2F2F2;

				text {
					font-size: 26rpx;

					&:nth-child(1) {
						color: #666666;
					}

					&:nth-child(2) {
						color: #333333;
						width: 470rpx;
						text-align: right;
					}
				}

				image {
					&:nth-child(3) {
						width: 30rpx;
						margin-left: 50rpx;
					}
				}
			}

			.end_time {
				width: 94%;
				margin-left: 3%;
				height: 90rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				border-bottom: 1px solid #F2F2F2;

				text {
					font-size: 26rpx;

					&:nth-child(1) {
						color: #666666;
					}

					&:nth-child(2) {
						color: #333333;
						width: 470rpx;
						text-align: right;
					}
				}

				image {
					&:nth-child(3) {
						width: 30rpx;
						margin-left: 50rpx;
					}
				}
			}

			.reason {
				width: 94%;
				margin-left: 3%;
				height: 90rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					font-size: 26rpx;

					&:nth-child(1) {
						color: #666666;
					}

					&:nth-child(2) {
						width: 520rpx;
						color: #333333;
						text-align: right;
					}

					&:nth-child(3) {
						width: 0rpx;
						margin-left: 50rpx;
						margin-top: 20rpx;
						height: 0rpx;
						border-width: 18rpx 18rpx 18rpx 18rpx;
						border-color: #ccc transparent transparent transparent;
						border-style: solid;
					}
				}
			}

			.adjunct {
				width: 94%;
				margin-left: 3%;
				height: 78rpx;
				display: flex;
				justify-content: flex-start;
				border-bottom: 1rpx solid #F2F2F2;
				align-items: center;

				.upload {
					color: #666666;
					font-size: 26rpx;
				}

				.num {
					width: 440rpx;
					margin-left: 120rpx;
					display: flex;
					justify-content: flex-end;

					text {
						color: #333333;
						font-size: 26rpx;

						&:nth-child(1) {}

						&:nth-child(2) {
							color: #2D81FE;
						}

						&:nth-child(3) {}
					}
				}
			}

			.results {
				width: 94%;
				margin-left: 3%;
				height: 90rpx;
				border-bottom: 1px solid #F2F2F2;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				.check {
					color: #666666;
					font-size: 26rpx;
					width: 500rpx;
				}

				.toggle {
					width: 160rpx;
					height: 40rpx;
					position: relative;

					text {
						&:nth-child(1) {
							border-top-left-radius: 20rpx;
							border-bottom-left-radius: 20rpx;
							background: #00cd97;
							color: #fff;
							text-align: center;
							line-height: 40rpx;
							height: 40rpx;
							font-size: 20rpx;
							width: 80rpx;
							position: absolute;
							top: 0;
							left: 0;
						}

						&:nth-child(2) {
							border-top-right-radius: 20rpx;
							border-bottom-right-radius: 20rpx;
							background: #F2F2F2;
							color: #333333;
							text-align: center;
							line-height: 40rpx;
							height: 40rpx;
							font-size: 20rpx;
							width: 80rpx;
							position: absolute;
							top: 0;
							left: 80rpx;
						}
					}
				}
			}

			.remark {
				width: 94%;
				height: 78rpx;
				margin-left: 3%;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				font-size: 26rpx;
				color: #666666;

			}
		}

		.confirm {
			width: 100%;
			height: 150rpx;
			display: flex;
			justify-content: center;
			align-items: center;

			.verify {
				width: 200rpx;
				height: 60rpx;
				border-radius: 50rpx;
				text-align: center;
				line-height: 60rpx;
				background: linear-gradient(to right, #2C78FE, #32B0FF);
				color: #fff;
				font-size: 30rpx;
			}
		}
	}
</style>
